<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>qooxdoo storage library</title>
    <script type="text/javascript" charset="utf-8" src="require.js"></script>
  </head>
  <body>
    <h1>qooxdoo storage library</h1>
    <div>Count: <span id="count">0</span> (click number to increment)</div>
    <script type="text/javascript" charset="utf-8">
      var countEl = document.getElementById("count");
      countEl.style.cursor = "pointer";

      require(["storage-require"], function(storage) {
        // use local storage
        var local = storage.getLocal();
        var key = "demo-count";

        // initialize the count
        var count = parseInt(local.getItem(key), 10);
        if (count) {
          countEl.innerHTML = count;
        } else {
          count = 0;
        }

        // increment on click
        var onClick = function() {
          count++;
          local.setItem(key, count);
          countEl.innerHTML = count;
        };
        if (countEl.addEventListener) {
          countEl.addEventListener("click", onClick, false);
        } else {
          countEl.attachEvent("onclick", onClick);
        }
      });
    </script>
  </body>
</html>